package com.ll.menu.user.history.list;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.droid.library.app.emptyview.BaseCallback;
import com.droid.library.app.emptyview.BaseEmptyViewManager;
import com.droid.library.app.emptyview.CallbackAdapter;
import com.droid.library.app.mvp.BaseMVPActivity;
import com.droid.library.app.mvp.IUI;
import com.droid.library.app.mvp.list.FooterManager;
import com.droid.library.widget.recyclerview.BaseRecyclerAdapter;
import com.ll.menu.user.R;
import com.ll.menu.user.app.entity.Order;

import butterknife.InjectView;
import butterknife.OnClick;

/**
 * 订单历史列表
 *
 * @author wangheng
 */

public class HistoryListActivity extends BaseMVPActivity<OrderHistoryListPresenter>
        implements IOrderHistoryListUI {

    @InjectView(R.id.flHistoryListEmptyContainer)
    ViewGroup mEmptyViewContainer;

    @InjectView(R.id.rvHistoryList)
    RecyclerView mRecyclerView;

    @InjectView(R.id.tvHistoryListUsername)
    TextView mUsernameTextView;

    private HistoryListEmptyViewManager mEmptyViewManager;
    private HistoryListAdapter mAdapter;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_history_list;
    }

    @Override
    protected void onCreateExecute(Bundle savedInstanceState) {
        initView();
        getPresenter().requestList();
    }

    private void initView() {
        mEmptyViewManager = new HistoryListEmptyViewManager(new CallbackAdapter());
        mEmptyViewManager.addEmptyViewToFirst(HistoryListActivity.this, mEmptyViewContainer);
        mEmptyViewManager.hideAllEmptyView();

        mAdapter = new HistoryListAdapter(HistoryListActivity.this);
        mRecyclerView.setAdapter(mAdapter);
    }

    @Override
    protected OrderHistoryListPresenter createPresenter() {
        return new OrderHistoryListPresenter();
    }

    @Override
    protected IUI getUI() {
        return HistoryListActivity.this;
    }

    @OnClick({R.id.ivHistoryListBack,R.id.tvHistoryListExitLogin})
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ivHistoryListBack:
                finishActivity();
                break;
            case R.id.tvHistoryListExitLogin:

                break;
            default:
                break;
        }
    }

    @Override
    public BaseRecyclerAdapter<Order> getAdapter() {
        return mAdapter;
    }

    @Override
    public void onPullDownRefreshCompleted() {

    }

    @Override
    public void onPullUpRefreshCompleted() {

    }

    @Override
    public FooterManager getFooterManager() {
        return null;
    }

    @Override
    public Bundle getExtras() {
        return null;
    }

    @Override
    public BaseEmptyViewManager<? extends BaseCallback> getEmptyViewManager() {
        return mEmptyViewManager;
    }

    public static void launch(Activity activity){
        Intent intent = new Intent(activity,HistoryListActivity.class);
        activity.startActivity(intent);
    }
}
